<template>
  <view>
    <view class="container">
      <view class="tabs-header">
        <up-tabs
          class="up-tabs-content"
          :list="tabsData"
          @click="onTabClick"
          :lineWidth="lineWidth"
          lineColor="#2877FF"
          :activeStyle="activeTabStyle"
          :inactiveStyle="inactiveTabStyle"
          itemStyle="padding-left: 15px; padding-right: 15px; height: 50px;"
        />
      </view>
      <!-- 表单内容 -->

      <CarForm
        :formData="formData"
        :list="list"
        :title="title"
        :plateColorPickerVisible="plateColorPickerVisible"
      />

      <!-- 查询按钮 -->
      <view class="btn-container">
        <u-button @click="goToquerycert()">立即查询</u-button>
      </view>
    </view>
  </view>
</template>
<script>
import CarForm from "@/pages/hub_zsyg/components/CarForm.vue";
import { changePlatecolor } from "@/common/util_complete.js";
export default {
  components: {
    CarForm,
  },
  data() {
    return {
      tabsData: [
        { name: "营运车辆", id: "1" },
        { name: "经营业户", id: "2" },
        { name: "从业人员", id: "3" },
      ],
      formData: {
        region: "",
        plateNumber: "",
        plateColor: "",
        transportNumber: "",
      },
      lineWidth: 60,
      activeTabStyle: {
        color: "#2877FF",
        fontSize: "16px",
        fontWeight: "bold",
      },
      userType: "1",
      inactiveTabStyle: {
        color: "#0D1444",
        fontSize: "16px",
        fontWeight: "normal",
      },
      list: [], // 车牌颜色选择
    };
  },
  onLoad(options) {
    // this.populateList(); // 在加载时填充数据
    this.list = changePlatecolor(this.list);
  },
  methods: {
    changeOpenCarColor() {
      this.$refs.carPicker._open();
    },
    //关闭选择器
    closeCarPicker() {
      this.$refs.carPicker._close();
    },
    confirmCarPicker(checkedValue) {
      this.formData.plateColor = checkedValue;
    },

    onTabClick(event, index) {
      this.userType = event.id;
    },
    goToquerycert() {
      uni.redirectTo({
        url: `/pages/hub_zsyg/cert/querycert?plateNumber=${this.formData.plateNumber}&plateColor=${this.formData.plateColor}&userType=${this.userType}`,
      });
    },
  },
};
</script>
<style lang="scss" scoped>
.container {
  width: 100%;
  padding: 10px;
  background-color: #f3f6fa;
  height: 100vh;
  box-sizing: border-box;
}
.tabs-header {
  background-color: #fff;
  height: 47px;
  margin-bottom: 10px;
  border-radius: 5px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}
.up-tabs-content {
  margin-top: 10px;
}

.btn-container {
  margin-top: 30px;
  text-align: center;
  width: 100%;

  width: 100%;
  box-sizing: border-box;
  ::v-deep .u-button--info[data-v-461e713c] {
    width: 100%;
    background-color: #2877ff;
    color: #ffffff;
  }
}
</style>
